/**
 * \file constants.hpp
 * 
 * \section COPYRIGHT
 *
 * Basis: A 3D Mathematics Library
 *
 * ---------------------------------------------------------------------
 *
 * Copyright (c) 2010, Don Olmstead
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *  1. Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *
 *  2. Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the documentation
 *     and/or other materials provided with the distribution.
 *
 *  3. Neither the name of organization nor the names of its contributors may be
 *     used to endorse or promote products derived from this software without
 *     specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef BASIS_CONSTANTS_HPP_INCLUDED
#define BASIS_CONSTANTS_HPP_INCLUDED

#include <cmath>

#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288
#endif

#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880168872420969808
#endif

#ifndef M_SQRT3
#define M_SQRT3 1.732050807568877293527446341505
#endif

#ifndef M_E
#define M_E 2.71828182845904523536028747135266250
#endif

#ifndef DEG_PER_RAD
#define DEG_PER_RAD 57.295779513082320876798154814105
#endif

#ifndef RAD_PER_DEG
#define RAD_PER_DEG 0.01745329251994329576923690768489
#endif

namespace basis
{
	/**
	 * Contains commonly used precalculated values.
	 *
	 * \tparam Real A real number type.
	 *
	 * \author Don Olmstead
	 * \version 0.1
	 */
	template <typename Real>
	class constants
	{
		//------------------------------------------------------------
		// Logarithmic constants
		//------------------------------------------------------------

		public:

			/**
			 * Represents the mathematical constant e.
			 *
			 * \returns The mathematical constant e.
			 */
			static inline Real e()
			{
				return Real(M_E);
			}

		//------------------------------------------------------------
		// PI constants
		//------------------------------------------------------------

		public:

			/**
			 * Represents the value of pi.
			 *
			 * \returns The value of pi.
			 */
			static inline Real pi()
			{
				return Real(M_PI);
			}

			/**
			 * Represents the value of pi over two.
			 *
			 * \returns The value of pi over two.
			 */
			static inline Real pi_over_two()
			{
				return Real(M_PI * 0.5);
			}

			/**
			 * Represents the value of pi over four.
			 *
			 * \returns The value of pi over four.
			 */
			static inline Real pi_over_four()
			{
				return Real(M_PI * 0.25);
			}

			/**
			 * Represents the value of pi times two.
			 *
			 * \returns The value of pi times two.
			 */
			static inline Real two_pi()
			{
				return Real(M_PI * 2.0);
			}

			/**
			 * Represents the value of pi times four.
			 *
			 * \returns The value of pi times four.
			 */
			static inline Real four_pi()
			{
				return Real(M_PI * 4.0);
			}

		//------------------------------------------------------------
		// Radian/Degrees constants
		//------------------------------------------------------------

		public:

			/**
			 * Represents the number of radians per degree.
			 *
			 * \returns The number of radians per degree.
			 */
			static inline Real radians_per_degree()
			{
				return Real(RAD_PER_DEG);
			}

			/**
			 * Represents the number of degrees per radian.
			 *
			 * \returns The number of degrees per radian.
			 */
			static inline Real degrees_per_radian()
			{
				return Real(DEG_PER_RAD);
			}

		//------------------------------------------------------------
		// Square root constants
		//------------------------------------------------------------

		public:

			/**
			 * Represents the square root of two.
			 *
			 * \returns The square root of two.
			 */
			static inline Real sqrt_two()
			{
				return Real(M_SQRT2);
			}

			/**
			 * Represents the square root of three.
			 *
			 * \returns The square root of three.
			 */
			static inline Real sqrt_three()
			{
				return Real(M_SQRT3);
			}

			/**
			 * Represents the inverse of the square root of two.
			 *
			 * \returns The inverse of the square root of two.
			 */
			static inline Real inv_sqrt_two()
			{
				return Real(1.0 / M_SQRT2);
			}

			/**
			 * Represents the inverse of the square root of three.
			 *
			 * \returns The inverse of the square root of three.
			 */
			static inline Real inv_sqrt_three()
			{
				return Real(1.0 / M_SQRT3);
			}

		private:

			/**
			 * Default constructor.
			 *
			 * Private to disallow creation of instances.
			 */
			constants() { }

	} ; // end class constants

} // end namespace basis

#endif // end BASIS_CONSTANTS_HPP_INCLUDED
